import ReactECharts from "echarts-for-react";

const Pie = (props) => {

  const PieName = props.name ? props.name : '标题' // 饼图标题
  const data = props.data ? props.data : [ {value: 1, name: 'Item'} ] // 设置数据
  const radius = props.radius ? props.radius : '50%' // 饼图占比大小
  const width = props.width ? props.width : 500 // 宽度
  const height = props.height ? props.height : 400 // 高度

  const options = {
    title: {
      text: PieName,
      left: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    series: [
      {
        name: '',
        type: 'pie',
        radius: radius,
        data: data,
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  };

  return <ReactECharts style={{width: width, height: height}} option={options} />
}

export default Pie
